<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath() + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=path%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery-1.42.min.js"></script>
<title>实名认证</title>
<style>
.m-t {
	margin-top: 60px;
}
</style>
</head>
<body>
	<div class="col-sm-12" style="min-height: 100%">
		<div class="ibox float-e-margins">
			<div class="ibox-content m-t">
				<form method="post" class="form-horizontal" id="realNameForm"
					action="sns/uploadePhone" enctype="multipart/form-data">
					<div class="form-group">
						<label class="col-sm-2 control-label">真实姓名：</label>
						<div class="col-sm-8 input-group">
							<input type="text" class="form-control" id="name"
								placeholder="请输入2到10位的中文姓名" name="realname"> <span
								id="msg1"></span>
						</div>
						<p class="errorinfo col-sm-offset-2"
							style="color: red; text-align: left;"></p>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">身份证号：</label>
						<div class="col-sm-8 input-group">
							<input type="text" class="form-control" id="card"
								placeholder="请输入18位什么证号" name="idcard"> <span id="msg2"></span>
						</div>
						<p class="errorinfo col-sm-offset-2"
							style="color: red; text-align: left;"></p>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">身份证正面照：</label>
						<div class="col-sm-8 input-group">
							<input type="file" class="form-control" id="picture"
								placeholder="请选择身份证正面照" name="file"> <span id="msg3"></span>
						</div>
						<p class="errorinfo col-sm-offset-2"
							style="color: red; text-align: left;"></p>
					</div>
					<div class="form-group">
						<!--选择的文件展示的位置  -->ut
						<!-- <img alt="" src=""> -->
						<div class="imgdiv col-sm-offset-2"></div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<div class="col-sm-4 col-sm-offset-2">
							<button  class="btn btn-primary"  type="submit"
							onclick="save()"
							>保存</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script type="text/javascript">
			
		//核实姓名的方法
		var flag1 =0;
		function checkName(){
			var name=/^([\u4e00-\u9fa5]){2,7}$/;
			if(!name.test($("#name").val())){
				$("#msg1").html("请输入2到7位的中文姓名");
				flag1=101;
			}else{
				$("#msg1").html("");
				flag1=200;
			}
			return flag1;
		}
		
		//鼠标离开事件调用核实姓名的方法
		$("#name").blur(function (){
			checkName();
		})
		
		//核实身份证的方法
		var fla2 =0;
		function checkidCard(){
			var idCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; 
			if(!idCard.test($("#card").val())){
				$("#msg2").html("身份证号不合法");
				flag2=101;
			}else{
				$("#msg2").html("");
				flag2=200;
			}
			return flag2;
		}
		//鼠标离开事件调用身份证的方法
		$("#card").blur(function (){
			checkidCard();
		})
		
		
		
		
	$("#picture").change(function () {
		checkphoto();
	});
		var flag3 =200;
		function checkphoto(){
			var s = $('#picture').val();
	    	var start = s.indexOf(".") + 1;
	    	var name = s.substring(start, s.length).toLowerCase();
	    	if (name != "jpg" && name != "png" && name != "gif" && name !="jpeg") {
	        alert("图片格式必须为jpg、png、gif中的一种");
	      
	        $("[value='上传']").attr("disabled", true);
	        flag3=101;
	  	  }
	    	
	    /* var objUrl = getObjectURL(this.files[0]);
	    if (objUrl) {
	        $("#img0").attr("src", objUrl);
	    }
	    $("[value='上传']").attr("disabled", false); */
	    	return flag3;
		}
		
			function save(){
			var flag1= checkName();
			var flag2= checkidCard();
			var flag3= checkphoto();
			
			if(flag1==101){
				alert("姓名填写不合法");
			}else if(flag2==101){
				alert("身份证号不合法");
			}else if(flag3==101){
				alert("图片格式必须为jpg、png、gif中的一种");
			}else{
				alert("确定提交吗");
			}
			
		}
		
		
	</script>
</body>
</html>